﻿using IcicleFramework.Entities;
using Microsoft.Xna.Framework;

namespace IcicleFramework.Actions
{
    public abstract class GameAction : IGameAction
    {
        public event OnGameActionFinishedHandler OnGameActionFinished;

        protected bool finished;

        public bool Finished
        {
            get { return finished; }
            protected set
            {
                finished = value;

                if (finished && OnGameActionFinished != null)
                    OnGameActionFinished(this);
            }
        }

        public IGameObject Parent { get; set; }

        public bool Paused { get; protected set; }

        public IGameObject Target { get; set; }

        protected GameAction() { }

        protected GameAction(GameAction old) { }

        public abstract void Update(GameTime gameTime);

        public abstract IGameAction DeepClone();

        #region IPauseable Methods

        public void Pause()
        {
            if (!Paused)
            {
                Paused = true;
            }
        }

        public void Resume()
        {
            if (Paused)
            {
                Paused = false;
            }
        }

        #endregion

    }
}
